<?php
include("../../advertisement/model.php");
include("../../type/model.php");
include("../view/basefunction.php");

// 从数据库里查询出这个产品的信息
$advertisement = model_get_advertisement_details($_GET["id"]);
$body_html = represent_edit_form($advertisement);

include_once("../template/layout.php");

// ---------------------------------
// view
// ---------------------------------
function represent_edit_form($advertisement)
{
	$htmlData = '';
	if (!empty($advertisement['details']))
	{
		if (get_magic_quotes_gpc())
		{
			$htmlData = stripslashes($advertisement['details']);
		} else
		{
			$htmlData = $advertisement['details'];
		}
	}

	$form_html =
"<script charset='utf-8' src='../editor/kindeditor.js'></script>
<script>
	KE.show({
		id : 'details',
		cssPath : './index.css',
		imageUploadJson : '../../php/upload_json.php',
		fileManagerJson : '../../php/file_manager_json.php',
		allowFileManager : true,
		afterCreate : function(id) {
			KE.event.ctrl(document, 13, function() {
				KE.sync(id);
				document.forms['example'].submit();
			});
			KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
				KE.sync(id);
				document.forms['example'].submit();
			});
		}
	});
</script>
<form action='./edit_post.php' method='post' enctype='multipart/form-data'>
<input type='hidden' name='id' value='" . $advertisement["id"] . "'/>
广告方案名称：<input type='text' name='name' value='" . $advertisement["name"] . "' /><br />
详细内容：<br />
<textarea id='details' name='details' style='width:700px;height:300px;visibility:hidden;'>"
. htmlspecialchars($htmlData) .
"
</textarea>
<input type='submit' value='更新' />
</form>";

	return $form_html;
}

?>
